package com.jrx.anytxn.reporting.controller;

import com.jrx.anytxn.common.data.TxnRespCode;
import com.jrx.anytxn.common.exception.TxnBizException;
import com.jrx.anytxn.customer.dto.customer.CustomerPageRes;
import com.jrx.anytxn.i18n.response.TxnRespResult;
import com.jrx.anytxn.reporting.dto.MrCustomerInfoRes;
import com.jrx.anytxn.reporting.service.ICustomerDataDealService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jrx.auth.filter.service.InfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author xqy
 * @version 1.0
 * @date 2020/4/14
 */
@Api(tags = "监管报送的客户信息接口")
@RestController
@RequestMapping(value = "/mr/customer")
public class MrCustomerController {

    private static Logger logger = LoggerFactory.getLogger(MrCustomerController.class);

    @Autowired
    private ICustomerDataDealService customerDataDealService;

    @Autowired
    private InfoService infoService;


    @ApiOperation(value = "监管报送的客户信息集合查询接口")
    @GetMapping(value = "/customerList")
    public TxnRespResult<ArrayList<MrCustomerInfoRes>> getMrCustomersByCusIdOrMobileOrIdNumber(@RequestParam String mobile, @RequestParam String idNumber, @RequestParam String customerId) {
        TxnRespResult<ArrayList<MrCustomerInfoRes>> result = new TxnRespResult();
            String tenantId=String.valueOf(infoService.getUser().getProjectId());
            List<MrCustomerInfoRes> mrCustomers = customerDataDealService.getMrCustomersByCusIdOrMobileOrIdNumber(customerId, mobile, idNumber, tenantId);
            result.getSuccess((ArrayList)mrCustomers);
        return result;
    }

    @ApiOperation(value = "监管报送的客户信息详情查询接口")
    @GetMapping(value = "/customerInfo")
    public TxnRespResult<ArrayList<MrCustomerInfoRes>> getMrCustomersByCusIdOrMobileOrIdNumber( @RequestParam String channel, @RequestParam String customerId) {
        TxnRespResult<ArrayList<MrCustomerInfoRes>> result = new TxnRespResult();
        String tenantId=String.valueOf(infoService.getUser().getProjectId());
        MrCustomerInfoRes mrCustomer = customerDataDealService.getMrCustomersByTenantIdAndChannelAndcustomerId(tenantId,channel,customerId);
        ArrayList list = new ArrayList<>();
        list.add(mrCustomer);
        result.getSuccess(list);
        return result;
    }
}